﻿using System;
using System.Collections.Generic;
using Blader.ActionHandler;

namespace Blader.UI
{
    public class MenuItemCollection
    {
        private static List<MenuItem> menuItems = new List<MenuItem>();

        public static List<MenuItem> MenuItems
        {
            get { return menuItems; }
        }

        static MenuItemCollection()
        {
            menuItems.Add(new MenuItem("OpenSql", "&Open Sql", "Open Selected Sql File", typeof(SqlOpenHandler)));
            menuItems.Add(new MenuItem("RefreshCache", "&Refresh Cache", "Refresh Cache", typeof(RefreshCacheHandler)));
            menuItems.Add(new MenuItem("Setting", "&Setting", "Settings", typeof(SettingHandler)));
            menuItems.Add(new MenuItem("About", "&About", "About", typeof(AboutHandler)));
        }

        public static MenuItem FindByName(string name)
        {
            string commandName = name.Substring(name.LastIndexOf('.') + 1);

            return menuItems.Find(menuItem => commandName.Equals(menuItem.Name, StringComparison.CurrentCultureIgnoreCase));
        }
    }
}
